#include "jianzhi/7.h"
#include "gtest/gtest.h"

TEST(TestJianzhiSolutions, TestProblem7)
{
    jianzhi_7::Solution s;
    vector<int> preorder{3, 9, 20, 15, 7};
    vector<int> inorder{9, 3, 15, 20, 7};
    auto res = s.buildTree(preorder, inorder);

    TreeNode n1(3), n2(9), n3(20), n4(15), n5(7);
    n1.left = &n2;
    n1.right = &n3;
    n3.left = &n4;
    n3.right = &n5;

    ASSERT_TRUE(treeEqual(res, &n1));
    deleteTree(res);
}